package com.dy.interruptThread;

public class InterruptThread {
    public static void main(String[] args) throws InterruptedException {
        System.err.println("main开始");
        TestThread myThread = new TestThread();
        myThread.start();
        Thread.sleep(10);
        //向myThread发出中断指令，等待其终止
        myThread.interrupt();
        myThread.join();

        System.err.println("main结束");

    }
}
class TestThread extends Thread{
    @Override
    public void run(){
        int n = 0;
        while (!interrupted()){
            n++;
            System.err.println(n+"hello");
        }
    }
}
